// JavaScript Document
$(document).ready(function(e) {
    var languageId = "2";
	$(".language").click(function(e) {
		$(this).css("color","#666666");
		$(this).siblings().css("color","#177b95");
        languageId = $(this).attr("data-id");
		queryHeatMap();
    });
	$("div#content img").click(function(e) {
		switch (parseInt($(this).attr("data-index"))) {
		case 1:
			window.open(ctx + "/pages/web/news/newsList.jsp?language=" + languageId, "_self");
			break;
		case 3:
			window.open(ctx + "/pages/web/case/case.jsp?language=" + languageId, "_self");
			break;
		case 2:
			window.open(ctx + "/pages/web/product/product.jsp?categoryType=1&language=" + languageId, "_self");
			break;
		case 4:
			window.open(ctx + "/company/web/getAboutUs.do?languageId=" + languageId + "&flag=1", "_self");
			break;
		case 5:
			window.open(ctx + "/company/web/getAboutUs.do?languageId=" + languageId + "&flag=0", "_self");
			break;
		case -1:
			window.open(ctx + "/pages/web/index.jsp", "_self");
			break;
		default:
			break;
		}
        //window.open("../web/main.jsp?language=" + languageId + "&pageIndex=" + $(this).attr("data-index"), "_self");
    });
	    
	queryHeatMap();
		
	function queryHeatMap() {
		$.getJSON(ctx + "/home/web/heatMap/queryHeatMap.do",{languageId:languageId}, function(data, status){
			$("#marquee").empty();
			$.each(data, function(index, d) {
				var href = $("<a></a>");
				switch(d.linkedHeatMapType) {
					case 0:
						href.attr("href",
							ctx + "/news/web/heatMap/" + d.linkedHeatMapLinkedId + ".do?languageId=" + languageId);
						break;
					case 1:
					    href.attr("href",ctx + "/product/web/heatMap/" + d.linkedHeatMapLinkedId 
						                     + ".do?languageId=" + languageId).attr("target","_blank");
						break;
					case 2:
					    href.attr("href",ctx + "/successfulCase/web/heatMap/" + d.linkedHeatMapLinkedId 
											 + ".do?languageId=" + languageId).attr("target","_blank");
						break;
					default :
						break;
				}
				if(d.fileInfoId) {
					href.append($("<img>").attr("src",ctx + "/home/imagesrc.do?fileInfoId=" + d.fileInfoId)
							  .attr("width","207px").attr("height","72px").css("margin","14px").attr("title",d.heatMapDesc));
				} else {
					href.append($("<img>").attr("src",ctx + "/home/imagesrc.do?fileInfoId=" + d.uploadFileInfoId)
							  .attr("width","207px").attr("height","72px").css("margin","14px").attr("title",d.heatMapDesc));
				}
				
			    $("#marquee").append(href);
			});
		});
	}
			
});